<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
    <title>popularize - 推广后台</title>
    <link href="__STATIC__/public/css/bootstrap.min.css" rel="stylesheet">
    <link href="__STATIC__/public/fontawesome-free-5.8.2-web/css/all.css" rel="stylesheet">
    <link href="__STATIC__/admin/css/index.css" rel="stylesheet">
</head>

<body>
    <header>
        <div class="jumbotron">
            <h1>欢迎{if $Think.session.userinfo}后台用户<a href="javascript:;">{$Think.session.userinfo.username}{/if}</a>！</h1>
            <h2>
                {if $Think.session.userinfo.superiorname != "BOSS"}
                    {if $Think.session.userinfo}
                        我的上级:<a href="javascript:;">{$Think.session.userinfo.superiorname}</a>
                    {/if}
                {else /}
                    身份:<a href="javascript:;">{$Think.session.userinfo.superiorname}</a>
                {/if}
            </h2>
            <p>公司财产:&nbsp;<a href="javascript:;">{$companymoney}￥</a></p>
            <p><a class="btn btn-primary" role="button" href="{:Url('home/Index/index')}">前台页面</a></p>
            {if $Think.session.userinfo}
                <a class="btn btn-danger" role="button" href="{:Url('logout')}">注销</a>
            {else /}
                <a class="btn btn-primary" role="button" href="{:Url('login')}">登录</a>
            {/if}
            {if $Think.session.userinfo.superior_id == 0}
                <a class="btn btn-danger" role="button" href="{:Url('emptytable')}">清空数据表</a>
            {/if}
            <p><a class="btn btn-primary" role="button" href="{:Url('insert')}">新增用户</a></p>
        </div>
    </header>
    <main>
        <div style="background-color: #fff" class="jumbotron">
            <div class="user-table">
                <h1>用户表</h1>
                <table class="table table-condensed table-center table-hover">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>用户</th>
                        {if $Think.session.userinfo.superior_id == 0}
                            <th>密码（MD5加密）</th>
                        {/if}
                        <th>上级编号</th>
                        <th>关系编号列表</th>
                        <th>时间戳</th>
                        {if $Think.session.userinfo.superior_id == 0}
                            <th>操作</th>
                        {/if}
                    </tr>
                    </thead>
                    <tbody>
                        {if $users}
                        {volist name="users" id="row"}
                        <tr>
                            <td>{$row.id}</td>
                            <td>{$row.username}</td>
                            {if $Think.session.userinfo.superior_id == 0}
                                <td>{$row.password}</td>
                            {/if}
                            <td>{$row.superior_id}</td>
                            <td>{$row.rela_id_list}</td>
                            <td>{$row.timestamp}</td>
                            <td>
                                {if $Think.session.userinfo.superior_id == 0}
                                    {if $row.superior_id == !0}
                                        <a class="btn btn-primary" role="button" href="{:Url('revenue', array('user_id' => $row['id']))}">编辑收入</a>
                                    {else /}
                                    <a style="cursor: no-drop;" class="btn btn-danger" role="button" href="javascript:;">BOSS</a>
                                    {/if}
                                {/if}
                            </td>
                        </tr>
                        {/volist}
                        {/if}
                    </tbody>
                </table>
            </div>
            <div class="rela-table">
                <h1>关系表</h1>
                <table class="table table-condensed table-center table-hover">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>最高级用户编号</th>
                        <th>关系链</th>
                        <th>最低级用户编号</th>
                        <th>级</th>
                    </tr>
                    </thead>
                    <tbody>
                        {if $relas}
                            {volist name="relas" id="row"}
                                <tr>
                                    <td>{$row.id}</td>
                                    <td>{$row.max_id}</td>
                                    <td>{$row.path}</td>
                                    <td>{$row.min_id}</td>
                                    <td>{$row.level}</td>
                                </tr>
                            {/volist}
                        {else /}
                            <td style="color: #666;" colspan="5">暂无数据...</td>
                        {/if}
                    </tbody>
                </table>
            </div>
            <div class="tree-table">
                <h1>我的下级</h1>
                <table class="table table-condensed table-hover">
                    <thead>
                    <tr>
                        <th>用户</th>
                        <th>收益</th>
                    </tr>
                    </thead>
                    <tbody>
                    {if $trees}
                        {volist name="trees" id="row1"}
                            <tr class="parent">
                                <td><a href="javascript:;"><i class="fas fa-plus"></i>&nbsp;{$row1.username}</a></td>
                                <td></td>
                            </tr>
                            {volist name="$row1['child']" id="child"}
                                <tr style="display: none;" class="child">
                                    <td><a style="cursor: auto;" href="javascript:;">&nbsp;&nbsp;&nbsp;<i class="fas fa-minus"></i>&nbsp;{$child.username}</a></td>
                                    <td>{$child.money}</td>
                                </tr>
                            {/volist}
                        {/volist}
                    {else /}
                        <td style="color: #666;" colspan="2">暂无数据...</td>
                    {/if}
                    </tbody>
                </table>
            </div>
            <div class="personalrevenue-table">
                <h1>个人营收表</h1>
                {if $Think.session.userinfo.superior_id == 0}
                    <a class="btn btn-danger" role="button" href="{:Url('emptyrevenue')}">清空个人营收表</a>
                    <a class="btn btn-primary" role="button" href="{:Url('calculation')}">计算工资</a>
                {/if}
                <table class="table table-condensed table-center table-hover">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>用户</th>
                        <th>创造收入</th>
                        <th>工资</th>
                        <th>月份</th>
                        <th>时间戳</th>
                    </tr>
                    </thead>
                    <tbody>
                    {if $revenues}
                        {volist name="revenues" id="row"}
                            <tr>
                                <td>{$row.id}</td>
                                <td>编号:{$row.user_id} {$row.username}</td>
                                <td>{$row.income}</td>
                                <td>{$row.wages}</td>
                                <td>{$row.months}</td>
                                <td>{$row.timestamp}</td>
                            </tr>
                        {/volist}
                    {else /}
                        <td style="color: #666;" colspan="6">暂无数据...</td>
                    {/if}
                    </tbody>
                </table>
            </div>
        </div>
    </main>

    <script src="__STATIC__/public/js/jquery-3.4.1.min.js"></script>
    <script src="__STATIC__/admin/js/index.js"></script>
</body>

</html>